<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>基本列表</title>

  <!-- 引入Vue -->
  <script type="text/javascript" src="/vue/vue.js"></script>

</head>
<body>
  <!-- 创建一个容器 -->
  <div id="app">

    <!-- 遍历数组 -->
    <button @click.once="add">增加一个人员</button>
    <ul>
      <li v-for="(person, index) of persons" :key="index" >
        {{person.name}}
        <input type="text">
      </li>
    </ul> 

  </div>

  <script type="text/javascript">
    // 创建一个Vue实例
    new Vue({
      el: '#app',
      data: {
        persons: [
          {id:'001', name: '李四', age: 18, sex: '男' },
          {id:'002', name: '王五', age: 19, sex: '女' },
          {id:'003', name: '张三', age: 20, sex: '女' },
        ],
      
      },
      methods: {
        add() {
          this.persons.unshift({ name: '小明', age: 21, age: '男'});
        }
      },
    })
  </script>
</body>
</html>